/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: fzykd
 * Date: 2022-11-05
 * Time: 14:56
 */
class Node {
    public int val;
    public Node next;

    public Node(int val){
        this.val = val;
    }
}

//使用链表实现一个队列
public class MyQueue {
    public Node head;
    public Node last;

    //入队 尾插法
    public void add(int val){
        Node node = new Node(val);
        if (head == null){
            head = node;
            last = node;
        }
        last.next = node;
        last = last.next;
    }

    //出队
    public int remove(){
        if (head == null){
            System.out.println("队列为空!");
            return -1;
        }
        int ret = head.val;
        head = head.next;
        return ret;
    }


}
